<?php
putenv("DISPLAY=:1");
putenv("XAUTHORITY=/var/www/.Xauthority");

ini_set('display_errors', 1);
error_reporting(E_ALL);

include_once 'Bot.php';
include_once 'Api.php';

$skype = $argv[1];
$text  = urldecode($argv[2]);

if (!$skype) {
    exit();
}

$dbus = new Dbus(Dbus::BUS_SESSION, true);
$n = $dbus->createProxy('com.Skype.API', '/com/Skype', 'com.Skype.API');
$n->Invoke('NAME SEND_ASSIGN');
$n->Invoke('PROTOCOL 8');
$dbus->registerObject('/com/Skype/Client', 'com.Skype.API.Client', 'Bot');

Bot::getInstance()->sendNotifyToSkype($skype, iconv("WINDOWS-1251","UTF-8", $text));
exit();